package com.hopes.bizz.risk.hid.dto;

import cn.hutool.core.date.DateUtil;
import com.hopes.bizz.risk.gis.constant.RiskStatisticsCycleEnum;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * @author lyb
 * @version 1.0
 * @date 2024/2/22 11:13
 */

@Data
public class RiskHidStatisticsDTO {

    private List<Long> orgId;

    private Integer hidSource;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "开始时间为必填项")
    private Date beginTime;

    @DateTimeFormat(pattern = "结束时间为必填项")
    @NotNull(message = "结束时间为必填项")
    private Date endTime;


    public RiskStatisticsCycleEnum getDateCycle() {
        long intervalDay = DateUtil.betweenDay(beginTime, endTime, true);
        if (intervalDay <= 31) {
            return RiskStatisticsCycleEnum.month;
        } else {
            return RiskStatisticsCycleEnum.year;
        }
    }

    public Date getEndTime() {
        return DateUtil.endOfDay(endTime);
    }
}
